#include "GameOverScene.h"
#include "WelcomeScene.h"

using namespace cocos2d;

CCScene* GameOverScene::scene(bool won) {
	CCScene *scene = CCScene::create();
	GameOverScene *layer = new GameOverScene();
	if (layer && layer->initWithParams(won)) {
		layer->autorelease();
		scene->addChild(layer);
		;
		return scene;
	}
	CC_SAFE_DELETE(layer);
	return NULL;

}

bool GameOverScene::initWithParams(bool won) {
	if (!CCLayer::init()) {
		return false;
	}
	CCMenuItemLabel *it0;
	if(won){
		it0 = CCMenuItemLabel::create(CCLabelTTF::create("Wygrales Gratulacje", "Thonburi", 34), this,menu_selector(GameOverScene::goBack));
	}else{
		it0 = CCMenuItemLabel::create(CCLabelTTF::create("Przegrales", "Thonburi", 34), this,menu_selector(GameOverScene::goBack));
	}

	CCMenu* pMenu = CCMenu::create(it0, NULL);
	pMenu->alignItemsVertically();
	this->addChild(pMenu);
	return true;
}

void GameOverScene::goBack(CCObject* sender) {
	CCScene *pScene = Welcome::scene();
	CCDirector::sharedDirector()->replaceScene(pScene);
}

